package com.example.network

import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST

/**
 * author: liliang
 * date: 1/19/21 8:32 PM
 * desc:
 */
interface TranslateApiService {

    @FormUrlEncoded
    @POST("translate?doctype=json")
    suspend fun translate(@Field("i") i: String): ApiResult<Result>
}

data class Result(
    val type: String,
    val elapsedTime: Int,
    val translateResult: List<List<TranslateResult>>
) {

    data class TranslateResult(val src: String, val tgt: String)
}

object TranslateApi {
    val retrofitService: TranslateApiService by lazy { retrofit.create(TranslateApiService::class.java) }
}